//
//  WmcManualInviteTeamMemeberVM.swift
//  YPWatermarkCamera
//
//  Created by yupao_ios_macmini06 on 2022/9/14.
//

import Foundation
import RxSwift

class WmcManualInviteTeamMemeberVM: WmcBaseVM {
    var teamAblum: WmcMediaTeamAlbumModel?

    /// 手动添加团队成员
    /// - Parameters:
    ///   - mobile: 手机号
    ///   - remark: 备注名
    /// - Returns: description
    func addTeamMember(mobile: String, remark: String, succeed: ((_ res: YPNetworkResponse) -> Void)?, failure: ((_ error: Error) -> Void)?) {
        guard let teamId = teamAblum?.teamId else {
            return
        }
        WmcMediaTeamManagerAPI.addMember(teamId: teamId, mobile: mobile, remark: remark).subscribe { res in
            guard let succeed = succeed else {
                return
            }
            succeed(res)
        } onError: { error in
            /// 牛逼坏了，走错误里了
            print("error code === \(error.localizedDescription)")
            guard let failure = failure else {
                return
            }
            failure(error)
        }.disposed(by: rx.disposeBag)
    }
}
